Ext.define('ECAT.controller.AllController', {
    extend: 'Ext.app.Controller',
    config: {
    	refs:{
    		topBar : 'topbar',
    		buttomBar : 'buttombar',
    		imageList : 'list_img_all',
    		homePage : '#homePage',
    		menuUp : '#btn_menu_up',
    		menuDown : '#btn_menu_down'
    	},
    	control: {
            '#btn_all' : {
            	tap : 'tapAllMenu'
            },
            imageList : {
            	swipe : 'swipeAll'
            },
            '#list_img_all img': {
                tap: 'tapImg'
            }
        }
    },
    tapAllMenu : function(btn, e, eOpts){
    	var allImageList = this.getImageList();
    	if(Ext.Viewport.getActiveItem() !== allImageList){
    		this.getButtomBar().setBtn('btn_all');
    		this.getTopBar().toImgListAll();
    		Ext.Viewport.setActiveItem(allImageList); 
    	}
    },
    swipeAll : function(allImageList,e){
    	if(e.direction == 'right'){
			 this.getMenuDown().fireEvent('tap');
    		 Ext.Viewport.animateActiveItem(
			        this.getHomePage(), 
			        {type:'slide',direction:'right',duration : 900}
			    );
			 this.getMenuUp().hide();
//			 allImageList.getScrollable().getScroller().scrollTo(0,0);
    	}
    },
    tapImg: function(img) {
     	var list = this.getListImgAll(),
     	    topbar = this.getTopBar();
    	ECAT.lib.showImageDetail(img, list, list, '全部', topbar.toImgListAll);
    }
});
